package com.itheima.controller;

import com.itheima.pojo.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * <dl>
 * <dd>描述: ~节点业务逻辑实现</dd>
 * <dd>创建时间：  14:22 2020/4/23</dd>
 * <dd>创建人： zz</dd>
 * <dt>版本历史: </dt>
 * <pre>
 * Date         Author      Version     Description
 * ------------------------------------------------------------------
 * 2020/4/23      guodong       1.0        1.0 Version
 * </pre>
 * </dl>
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @Value("${server.port}")
    private String port;


    /*
        http://127.0.0.1:8080/user/findUserById?id=1

       restful风格： http://127.0.0.1:8080/user/findUserById/1/2

       @RequestParam("id")
       @PathVariable("id")
       @PathVariable
     */
    @GetMapping("/findUserById/{id}")
    public User findUserById(@PathVariable Integer id){
        User user = userService.findUserById(id);
        user.setNote("生产者端口号： " + port);
        return user;

    }
}
